home *** CD-ROM | disk | FTP | other *** search
/ ftp.mactech.com 2010 / ftp.mactech.com.tar / ftp.mactech.com / thinkref / archive / THINKPascalUH2.1.sea / THINKPas Univ Hdr 2.1 / Interfaces / Components.p < prev    next >
Text File  |  1995-09-12  |  11KB  |  319 lines

  1. { Converted with MPW2TPas Tuesday, September 12, 1995 5:36:20 PM }
  2. {
  3.      File:        Components.p
  4.  
  5.      Contains:    Component Manager Interfaces.
  6.  
  7.      Version:    Technology:    System 7.5
  8.                  Package:    Universal Interfaces 2.1 in “MPW Latest” on ETO #18
  9.  
  10.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  11.                  All rights reserved.
  12.  
  13.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  14.                  stack.  Include the file and version information (from above)
  15.                  in the problem description and send to:
  16.                      Internet:    apple.bugs@applelink.apple.com
  17.                      AppleLink:    APPLE.BUGS
  18.  
  19. }
  20.  
  21.  UNIT Components;
  22.  INTERFACE
  23.  
  24.  
  25. {$IFC UNDEFINED __COMPONENTS__}
  26. {$SETC __COMPONENTS__ := 1}
  27.  
  28.   USES
  29.    ConditionalMacros, Types, MixedMode;
  30.  
  31. { $PUSH}
  32. { $ALIGN MAC68K}
  33. { $LibExport+}
  34.  
  35. CONST
  36.     kAppleManufacturer            = 'appl';                        { Apple supplied components }
  37.     kComponentResourceType        = 'thng';
  38.  
  39.     kAnyComponentType            = 0;
  40.     kAnyComponentSubType        = 0;
  41.     kAnyComponentManufacturer    = 0;
  42.     kAnyComponentFlagsMask        = 0;
  43.  
  44.     cmpWantsRegisterMessage        = $80000000;
  45.  
  46.     kComponentOpenSelect        = -1;                            { ComponentInstance for this open }
  47.     kComponentCloseSelect        = -2;                            { ComponentInstance for this close }
  48.     kComponentCanDoSelect        = -3;                            { selector # being queried }
  49.     kComponentVersionSelect        = -4;                            { no params }
  50.     kComponentRegisterSelect    = -5;                            { no params }
  51.     kComponentTargetSelect        = -6;                            { ComponentInstance for top of call chain }
  52.     kComponentUnregisterSelect    = -7;                            { no params }
  53.  
  54. { Component Resource Extension flags }
  55.     componentDoAutoVersion        = $1;
  56.     componentWantsUnregister    = $2;
  57.     componentAutoVersionIncludeFlags = $4;
  58.     componentHasMultiplePlatforms = $8;
  59.  
  60. { Set Default Component flags }
  61.     defaultComponentIdentical    = 0;
  62.     defaultComponentAnyFlags    = 1;
  63.     defaultComponentAnyManufacturer = 2;
  64.     defaultComponentAnySubType    = 4;
  65.     defaultComponentAnyFlagsAnyManufacturer = 3;
  66.     defaultComponentAnyFlagsAnyManufacturerAnySubType = 7;
  67.  
  68. { RegisterComponentResource flags }
  69.     registerComponentGlobal        = 1;
  70.     registerComponentNoDuplicates = 2;
  71.     registerComponentAfterExisting = 4;
  72.  
  73.  
  74. TYPE
  75.     ComponentDescription = RECORD
  76.         componentType:            OSType;                                    { A unique 4-byte code indentifying the command set }
  77.         componentSubType:        OSType;                                    { Particular flavor of this instance }
  78.         componentManufacturer:    OSType;                                    { Vendor indentification }
  79.         componentFlags:            LONGINT;                                { 8 each for Component,Type,SubType,Manuf/revision }
  80.         componentFlagsMask:        LONGINT;                                { Mask for specifying which flags to consider in search, zero during registration }
  81.     END;
  82.  
  83.     ResourceSpec = RECORD
  84.         resType:                OSType;                                    { 4-byte code  }
  85.         resID:                    INTEGER;
  86.     END;
  87.  
  88.     ComponentResource = RECORD
  89.         cd:                        ComponentDescription;                    { Registration parameters }
  90.         component:                ResourceSpec;                            { resource where Component code is found }
  91.         componentName:            ResourceSpec;                            { name string resource }
  92.         componentInfo:            ResourceSpec;                            { info string resource }
  93.         componentIcon:            ResourceSpec;                            { icon resource }
  94.     END;
  95.  
  96.     ComponentResourcePtr = ^ComponentResource;
  97.     ComponentResourceHandle = ^ComponentResourcePtr;
  98.  
  99.     ComponentPlatformInfo = RECORD
  100.         componentFlags:            LONGINT;                                { flags of Component }
  101.         component:                ResourceSpec;                            { resource where Component code is found }
  102.         platformType:            INTEGER;                                { gestaltSysArchitecture result }
  103.     END;
  104.  
  105.     ComponentResourceExtension = RECORD
  106.         componentVersion:        LONGINT;                                { version of Component }
  107.         componentRegisterFlags:    LONGINT;                                { flags for registration }
  108.         componentIconFamily:    INTEGER;                                { resource id of Icon Family }
  109.     END;
  110.  
  111.     ComponentPlatformInfoArray = RECORD
  112.         count:                    LONGINT;
  113.         platformArray:            ARRAY [0..0] OF ComponentPlatformInfo;
  114.     END;
  115.  
  116.     ExtComponentResource = RECORD
  117.         cd:                        ComponentDescription;                    { registration parameters }
  118.         component:                ResourceSpec;                            { resource where Component code is found }
  119.         componentName:            ResourceSpec;                            { name string resource }
  120.         componentInfo:            ResourceSpec;                            { info string resource }
  121.         componentIcon:            ResourceSpec;                            { icon resource }
  122.         componentVersion:        LONGINT;                                { version of Component }
  123.         componentRegisterFlags:    LONGINT;                                { flags for registration }
  124.         componentIconFamily:    INTEGER;                                { resource id of Icon Family }
  125.         count:                    LONGINT;                                { elements in platformArray }
  126.         platformArray:            ARRAY [0..0] OF ComponentPlatformInfo;
  127.     END;
  128.  
  129.     ComponentParameters = PACKED RECORD
  130.         flags:                    CHAR;                                    { call modifiers: sync/async, deferred, immed, etc }
  131.         paramSize:                CHAR;                                    { size in bytes of actual parameters passed to this call }
  132.         what:                    INTEGER;                                { routine selector, negative for Component management calls }
  133.         params:                    ARRAY [0..0] OF LONGINT;                { actual parameters for the indicated routine }
  134.     END;
  135.  
  136.     ComponentRecord = RECORD
  137.         data:                    ARRAY [0..0] OF LONGINT;
  138.     END;
  139.  
  140.     Component = ^ComponentRecord;
  141.  
  142.     ComponentInstanceRecord = RECORD
  143.         data:                    ARRAY [0..0] OF LONGINT;
  144.     END;
  145.  
  146.     ComponentInstance = ^ComponentInstanceRecord;
  147.  
  148.     ComponentResult = LONGINT;
  149.  
  150.     ComponentRoutineProcPtr = ProcPtr;  { FUNCTION ComponentRoutine(VAR cp: ComponentParameters; componentStorage: Handle): ComponentResult; }
  151.     ComponentRoutineUPP = UniversalProcPtr;
  152.  
  153. CONST
  154.     uppComponentRoutineProcInfo = $000003F0; { FUNCTION (4 byte param, 4 byte param): 4 byte result; }
  155.  
  156. FUNCTION NewComponentRoutineProc(userRoutine: ComponentRoutineProcPtr): ComponentRoutineUPP;
  157.     {$IFC NOT GENERATINGCFM }
  158.     INLINE $2E9F;
  159.     {$ENDC}
  160.  
  161. FUNCTION CallComponentRoutineProc(VAR cp: ComponentParameters; componentStorage: Handle; userRoutine: ComponentRoutineUPP): ComponentResult;
  162.     {$IFC NOT GENERATINGCFM}
  163.     INLINE $205F, $4E90;
  164.     {$ENDC}
  165.     
  166. TYPE
  167.     ComponentRoutine = ComponentRoutineUPP;
  168.  
  169. {
  170.     The parameter list for each ComponentFunction is unique. It is 
  171.     therefore up to users to create the appropriate procInfo for their 
  172.     own ComponentFunctions where necessary.
  173. }
  174.     ComponentFunctionUPP = UniversalProcPtr;
  175.  
  176.  
  177. FUNCTION RegisterComponent(VAR cd: ComponentDescription; componentEntryPoint: ComponentRoutineUPP; global: INTEGER; componentName: Handle; componentInfo: Handle; componentIcon: Handle): Component;
  178.     {$IFC NOT GENERATINGCFM}
  179.     INLINE $7001, $A82A;
  180.     {$ENDC}
  181. FUNCTION RegisterComponentResource(tr: ComponentResourceHandle; global: INTEGER): Component;
  182.     {$IFC NOT GENERATINGCFM}
  183.     INLINE $7012, $A82A;
  184.     {$ENDC}
  185. FUNCTION UnregisterComponent(aComponent: Component): OSErr;
  186.     {$IFC NOT GENERATINGCFM}
  187.     INLINE $7002, $A82A;
  188.     {$ENDC}
  189. FUNCTION FindNextComponent(aComponent: Component; VAR looking: ComponentDescription): Component;
  190.     {$IFC NOT GENERATINGCFM}
  191.     INLINE $7004, $A82A;
  192.     {$ENDC}
  193. FUNCTION CountComponents(VAR looking: ComponentDescription): LONGINT;
  194.     {$IFC NOT GENERATINGCFM}
  195.     INLINE $7003, $A82A;
  196.     {$ENDC}
  197. FUNCTION GetComponentInfo(aComponent: Component; VAR cd: ComponentDescription; componentName: Handle; componentInfo: Handle; componentIcon: Handle): OSErr;
  198.     {$IFC NOT GENERATINGCFM}
  199.     INLINE $7005, $A82A;
  200.     {$ENDC}
  201. FUNCTION GetComponentListModSeed: LONGINT;
  202.     {$IFC NOT GENERATINGCFM}
  203.     INLINE $7006, $A82A;
  204.     {$ENDC}
  205. { Component Instance Allocation and dispatch routines }
  206. FUNCTION OpenComponent(aComponent: Component): ComponentInstance;
  207.     {$IFC NOT GENERATINGCFM}
  208.     INLINE $7007, $A82A;
  209.     {$ENDC}
  210. FUNCTION CloseComponent(aComponentInstance: ComponentInstance): OSErr;
  211.     {$IFC NOT GENERATINGCFM}
  212.     INLINE $7008, $A82A;
  213.     {$ENDC}
  214. FUNCTION GetComponentInstanceError(aComponentInstance: ComponentInstance): OSErr;
  215.     {$IFC NOT GENERATINGCFM}
  216.     INLINE $700A, $A82A;
  217.     {$ENDC}
  218. { Direct calls to the Components }
  219. FUNCTION ComponentFunctionImplemented(ci: ComponentInstance; ftnNumber: INTEGER): LONGINT;
  220.     {$IFC NOT GENERATINGCFM}
  221.     INLINE $2F3C, $2, $FFFD, $7000, $A82A;
  222.     {$ENDC}
  223. FUNCTION GetComponentVersion(ci: ComponentInstance): LONGINT;
  224.     {$IFC NOT GENERATINGCFM}
  225.     INLINE $2F3C, $0, $FFFC, $7000, $A82A;
  226.     {$ENDC}
  227. FUNCTION ComponentSetTarget(ci: ComponentInstance; target: ComponentInstance): LONGINT;
  228.     {$IFC NOT GENERATINGCFM}
  229.     INLINE $2F3C, $4, $FFFA, $7000, $A82A;
  230.     {$ENDC}
  231. { Component Management routines }
  232. PROCEDURE SetComponentInstanceError(aComponentInstance: ComponentInstance; theError: OSErr);
  233.     {$IFC NOT GENERATINGCFM}
  234.     INLINE $700B, $A82A;
  235.     {$ENDC}
  236. FUNCTION GetComponentRefcon(aComponent: Component): LONGINT;
  237.     {$IFC NOT GENERATINGCFM}
  238.     INLINE $7010, $A82A;
  239.     {$ENDC}
  240. PROCEDURE SetComponentRefcon(aComponent: Component; theRefcon: LONGINT);
  241.     {$IFC NOT GENERATINGCFM}
  242.     INLINE $7011, $A82A;
  243.     {$ENDC}
  244. FUNCTION OpenComponentResFile(aComponent: Component): INTEGER;
  245.     {$IFC NOT GENERATINGCFM}
  246.     INLINE $7015, $A82A;
  247.     {$ENDC}
  248. FUNCTION CloseComponentResFile(refnum: INTEGER): OSErr;
  249.     {$IFC NOT GENERATINGCFM}
  250.     INLINE $7018, $A82A;
  251.     {$ENDC}
  252. { Component Instance Management routines }
  253. FUNCTION GetComponentInstanceStorage(aComponentInstance: ComponentInstance): Handle;
  254.     {$IFC NOT GENERATINGCFM}
  255.     INLINE $700C, $A82A;
  256.     {$ENDC}
  257. PROCEDURE SetComponentInstanceStorage(aComponentInstance: ComponentInstance; theStorage: Handle);
  258.     {$IFC NOT GENERATINGCFM}
  259.     INLINE $700D, $A82A;
  260.     {$ENDC}
  261. FUNCTION GetComponentInstanceA5(aComponentInstance: ComponentInstance): LONGINT;
  262.     {$IFC NOT GENERATINGCFM}
  263.     INLINE $700E, $A82A;
  264.     {$ENDC}
  265. PROCEDURE SetComponentInstanceA5(aComponentInstance: ComponentInstance; theA5: LONGINT);
  266.     {$IFC NOT GENERATINGCFM}
  267.     INLINE $700F, $A82A;
  268.     {$ENDC}
  269. FUNCTION CountComponentInstances(aComponent: Component): LONGINT;
  270.     {$IFC NOT GENERATINGCFM}
  271.     INLINE $7013, $A82A;
  272.     {$ENDC}
  273. { Useful helper routines for convenient method dispatching }
  274. FUNCTION CallComponentFunction(VAR params: ComponentParameters; func: ComponentFunctionUPP): LONGINT;
  275.     {$IFC NOT GENERATINGCFM}
  276.     INLINE $70FF, $A82A;
  277.     {$ENDC}
  278. FUNCTION CallComponentFunctionWithStorage(storage: Handle; VAR params: ComponentParameters; func: ComponentFunctionUPP): LONGINT;
  279.     {$IFC NOT GENERATINGCFM}
  280.     INLINE $70FF, $A82A;
  281.     {$ENDC}
  282. FUNCTION DelegateComponentCall(VAR originalParams: ComponentParameters; ci: ComponentInstance): LONGINT;
  283.     {$IFC NOT GENERATINGCFM}
  284.     INLINE $7024, $A82A;
  285.     {$ENDC}
  286. FUNCTION SetDefaultComponent(aComponent: Component; flags: INTEGER): OSErr;
  287.     {$IFC NOT GENERATINGCFM}
  288.     INLINE $701E, $A82A;
  289.     {$ENDC}
  290. FUNCTION OpenDefaultComponent(componentType: OSType; componentSubType: OSType): ComponentInstance;
  291.     {$IFC NOT GENERATINGCFM}
  292.     INLINE $7021, $A82A;
  293.     {$ENDC}
  294. FUNCTION CaptureComponent(capturedComponent: Component; capturingComponent: Component): Component;
  295.     {$IFC NOT GENERATINGCFM}
  296.     INLINE $701C, $A82A;
  297.     {$ENDC}
  298. FUNCTION UncaptureComponent(aComponent: Component): OSErr;
  299.     {$IFC NOT GENERATINGCFM}
  300.     INLINE $701D, $A82A;
  301.     {$ENDC}
  302. FUNCTION RegisterComponentResourceFile(resRefNum: INTEGER; global: INTEGER): LONGINT;
  303.     {$IFC NOT GENERATINGCFM}
  304.     INLINE $7014, $A82A;
  305.     {$ENDC}
  306. FUNCTION GetComponentIconSuite(aComponent: Component; VAR iconSuite: Handle): OSErr;
  307.     {$IFC NOT GENERATINGCFM}
  308.     INLINE $7029, $A82A;
  309.     {$ENDC}
  310.  
  311. { $ALIGN RESET}
  312. { $POP}
  313.  
  314. {$ENDC} {__COMPONENTS__}
  315.  
  316.  IMPLEMENTATION
  317.  END.
  318.  
  319.